<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <div>
            <a @click="path='Home'">home</a> |
            <a @click="path='List'">list</a>|
            <a @click="path='Car'">car</a>|
            <a @click="path='Mine'">mine</a>|
        </div>
        <div>
            <component :is="path"></component>
        </div>
    </div>
</body>
<template id="home">
    <div class="home">
        这是主页面
    </div>
</template>
<template id="list">
    <div class="list">
        这是列表页
    </div>
</template>
<template id="car">
    <div class="car">
        这是购物车
    </div>
</template>
<template id="mine">
    <div class="mine">
        这是个人页面
    </div>
</template>
<script>

    var Home = {
        data() {
            return {}
        },
        template: "#home"
    }

    var List = {
        data() {
            return {}
        },
        template: "#list"
    }

    var Car = {
        data() {
            return {}
        },
        template: "#car"
    }

    var Mine = {
        data() {
            return {}
        },
        template: "#mine"
    }




    var vm = new Vue({
        el: "#app",
        data: {
            count: 1,
            path: "home",
        },
        components: {
            Home: Home,
            List,
            Car,
            Mine,
        },
        provide: function () {
            return {
                count: this.count,
                getCount: () => this.count, //函数引用类型
                setCount: (v) => this.count = v,
            }
        }
    })





</script>

</html>